import { BaseDrawInfo } from "../base";
import { drawerAop } from "../drawer-aop";

export interface RingDrawInfo extends BaseDrawInfo {
  x: number; // 中心点
  y: number; // 中心点
  innerR: number; // 内圆半径
  outerR: number; // 外圆半径
}

export class RingHelper {
  static _helper: RingHelper = new RingHelper();
  static getInstance() {
    return this._helper;
  }

  protected constructor() {}

  @drawerAop({ dealStrokeFill: true })
  draw(ctx: CanvasRenderingContext2D, drawInfo: RingDrawInfo) {
    const { x, y, innerR, outerR } = drawInfo;
    ctx.ellipse(x, y, outerR, outerR, 0, 0, Math.PI * 2);
    ctx.ellipse(x, y, innerR, innerR, 0, 0, Math.PI * 2, true);
  }
}

export const ring = RingHelper.getInstance();
